﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;
using DevExpress.XtraTreeList.ViewInfo;
using DevExpress.XtraTreeList.Data;
using Tsingshan.RangeSelectSupportor;
using WindowsApplication4;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        RangeSelectSupportor rangeSelector;
        public Form1()
        {
            InitializeComponent();
            this.Resize += new EventHandler(Form1_Resize);
            BindData();
            rangeSelector = new RangeSelectSupportor(this.treeList1);
        }

        void Form1_Resize(object sender, EventArgs e)
        {
            //treeList1.Dock = DockStyle.Fill;
        }
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C");
            dt.Columns.Add("D");
            dt.Columns.Add("E");

            for (int i = 0; i < 100; i++)
            {
                dt.Rows.Add(new object[]
                                {
                                    "A" + i.ToString(),
                                    "B" + i.ToString(),
                                    "C" + i.ToString(),
                                    "D" + i.ToString(),
                                    "E" + i.ToString()
                                });
            }

            treeList1.DataSource = dt;
            treeList1.ExpandAll();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int i = rangeSelector.GetDataTableSelection().Count;
            List<DataTable> tables = rangeSelector.GetDataTableSelection();
            new Form2(tables).Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DataTable dt = rangeSelector.GetLastSelectDataTableRange();
            new Form2(dt).Show();
        }
    }
}
